<?php
namespace Admin\Controller;
use Think\Controller;

/**
* 推荐管理控制器
*/
class RecommendController extends CommonController{
	//推荐等级设置
	public function levelSet(){
		if($_POST){
			$res = M('dengji')->where('id='.$_POST['id'])->save($_POST);
			if($res === false){
				$this->error('修改失败');
			}else{
				$this->success('成功','levelList');
			}
		}else{
			$id = $_GET['id'] ? $_GET['id'] : 1;
			$data = M('dengji')->where('id='.$id)->find();
			$this->assign('data',$data);
			$this->display();
		}
		
	}
	//推荐等级列表
	public function levelList(){
		$data = M('dengji')->select();
		$this->assign('data',$data);
		$this->display();
	}
	//反馈记录
	public function feedList(){
		$page_no = I('get.p') ? I('get.p') : 1;
        $page_size = $_GET['page_size'] ? $_GET['page_size'] : 10;
		$data = M('feedback a')->field('a.id,a.user_id,a.content,a.image,a.add_time,a.status,b.username')
								->page($page_no, $page_size)
								->join('left join zm_user b on a.user_id=b.id')
								->where()->select();

		$count = M("feedback")->where($where)->count();
		$Page = new \AntAge\Page($count, $page_size);
        $show = $Page->show();
        $this->assign('page', $show);
        $this->assign("count", $count);
        $this->assign("data", $data);
        $this->display();
	}

	//反馈处理
	public function feedDeal(){
		$id = I('post.id');
		if(!$id){
			$this->ajaxReturn(array('status'=>0,'info'=>'参数错误'));
		}
		$res = M('feedback')->where('id='.$id)->save(array('status'=>1));
		if($res === false){
			$this->ajaxReturn(array('status'=>0,'info'=>'失败'));
		}
		$this->ajaxReturn(array('status'=>1,'info'=>'成功'));
	
	}
}